<template>
	<view class="hall">
		<!-- 顶部搜索 -->
		<view class="hall-box">
			<diySearch :bottom="'0rpx'" :color="'#FF6F30'" :inputJudge="true" @blur='blur' @determine='determine'></diySearch>
			<diy-screen ref="diyScreen" @determine='determine'></diy-screen>
		</view>
		<mescroll-body ref="mescrollRef" @down="downCallback" @up="upCallback" :up="upOption" :down="downOption" :top="210 +  $store.state.statusBarHeight">
			<!-- 任务展示 -->
			<diyTask :taskSwitch='taskSwitch' :taskList="taskList"></diyTask>
		</mescroll-body>
		<diyTabBar value="hall"></diyTabBar>
	</view>
</template>

<script>
	import diyTask from '../../component/diy-task/diy-task.vue'
	import diySearch from '../../component/diy-search/diy-search.vue'
	import diyTabBar from '../../component/diy-nav/diy-tabbar.vue'
	import diyScreen from '../../component/diy-screen/diy-screen.vue'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		components: {
			diyTabBar,diyTask,
			diySearch,diyScreen
		},
		mixins: [MescrollMixin],
		data(){
			return {
				taskList:[],
				//任务展开方式切换
				taskSwitch: false,
				// 刷新
				upOption: {
					page: {
						num: 0,
						size: 10
					}
				}, //上拉参数配置
				downOption: {
					auto: false,
					page: {
						num: 0,
						size: 10
					}
				}, //下拉参数配置
				obj:{}//返回的参数
			}
		},
		onLoad() {
			//#ifdef APP
			uni.hideTabBar()
			//#endif
		},
		onShow() {
			this.$nextTick(()=>{
				let height = uni.getSystemInfoSync().statusBarHeight;
				console.log('height',height)
			})
			this.$nextTick(()=>{
				if(this.mescroll) this.mescroll.resetUpScroll()
			})
		},
		methods:{
			// 下拉刷新
			downCallback(page) {
				this.mescroll.resetUpScroll()
			},
			//上拉加载
			upCallback(page) {
				this.$http.sendrequest('/task/TaskList', {
					page: page.num,
					page_size: page.size,
					name: '',
					...this.obj
				}).then(res => {
					if (res.code == 1) {
						if (page.num == 1) this.taskList = []; //如果是第一页需手动制空列表
						this.taskList = this.taskList.concat(res.data.list);
						if(res.data.list) this.mescroll.endBySize(res.data.list.length, res.data.count);
						if(this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				})
			},
			blur(obj){
				this.obj = Object.assign(this.obj,obj)
			},
			determine(obj){
				this.obj = Object.assign(this.obj,obj)
				this.mescroll.resetUpScroll()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.hall{
		min-height: 100vh;
		background:#f7f7f7;
		padding-bottom: 120rpx;
		box-sizing: border-box;
		.hall-box{
			position: fixed;
			top: 0;
			left:0;
			width: 100%;
			z-index: 9999;
		}
		.scroll{
			margin-top: 30rpx;
		}
	}

</style>